<template>
	<view class="wrap">
		<view class="cartListItem"
			v-for="(item,index) in orderList"
			:key="index"
			@tap="goOrderDet(item)"
		>
			<view class="sellerName hasFlex" v-if="item.ogzName != '' && item.ogzName != undefined">
				<view class="sellerImg">
					<image class="sellerImg" v-if="item.ogzHeadImg == ''" src="../../../../static/images/groupService/orgDef.png"></image>
					<image class="sellerImg" v-else :src="getCloudFilePath(item.ogzHeadImg)" lazy-load></image>
				</view>
				<view class="seller ellip">{{item.ogzName}}</view>
			</view>
			<view class="itemCon spaceBet">
				<view class="itemConImg defBg">
					<template v-if="currPageType == 'zxTcOrder'">
						<image class="samePar posAbso ltzero"  mode="aspectFill" :src="getCloudFilePath(item.teaImg)" lazy-load></image>
					</template>
					<template v-else>
						<image class="samePar posAbso ltzero" mode="aspectFill" :src="getCloudFilePath(item.zjHead)" lazy-load></image>
					</template>
				</view>
				<view class="itemConDet">
					<template v-if="currPageType == 'zxTcOrder'">
						<view class="topCon spaceBet">
							<view class="itemTit">{{item.tcName}}</view>
							<view class="itemStatus">
								<view class="waitPay" v-if="item.status == 0">待支付</view>
								<view class="wait" v-if="item.status == 1 && item.restTimes > 0">待咨询</view>
								<view class="hasComp" v-if="item.status == 1 && item.restTimes == 0">已完成</view>
								<view v-if="item.status == 7">已取消</view>
							</view>
						</view>
						<view class="midCon">咨询师:{{item.teaName}}</view>
						<view class="midCon spaceBet" v-if="item.status == 1">
							<text>咨询次数:{{item.tcTimes}}次</text>
							<view class="remainTimes">剩余次数:<text class="timesTxt">{{item.restTimes}}</text>次</view>
						</view>
						<view class="midCon" v-else>咨询次数:{{item.tcTimes}}次</view>
					</template>
					<template v-else>
						<view class="topCon spaceBet">
							<view>{{item.teaName}}咨询师</view>
							<view class="itemStatus">
								<view class="waitPay" v-if="item.payStatus == 0">待支付</view>
								<view class="wait" v-if="item.payStatus == 1">待咨询</view>
								<view class="hasComp" v-if="item.payStatus == 6">已完成</view>
								<view v-if="item.payStatus == 7">已取消</view>
							</view>
						</view>
						<view class="midCon">{{item.zxDate}} {{item.classTime}}</view>
						<view class="midCon">咨询方式:{{formatZxFun(item.zxType)}}</view>
						<view class="midCon specCol">¥{{item.money}}/{{item.zxMinute}}分钟</view>
					</template>
				</view>
			</view>
			<!-- 实付 --> 
			<view class="actPay spaceBet">
				<block v-if="item.payStatus == 0 || item.payStatus == 7 || item.payStatus == 7 || item.status == 7">
					<view class="actPayPrice">应付<text class="unit">¥</text><text class="priceNum">{{item.actMoney}}</text></view> 
				</block>
				<block v-else>
					<view class="actPayPrice">实付<text class="unit">¥</text><text class="priceNum">{{item.actMoney}}</text></view> 
				</block>
				<view class="groupBtn hasFlex">
					<block v-if="item.payStatus == 0 || item.status == 0">
						<view class="setBtn cancel" @tap.stop="cancelOrder(item.id)">取消订单</view>
						<view class="setBtn fix" @tap.stop="goPay(item)">去支付</view>
					</block>
					<block v-else-if="item.payStatus == 6 || item.status == 1">
						<template v-if="currPageType == 'zxTcOrder'">
							<view class="setBtn fix" v-if="item.restTimes > 0" @tap.stop="goZxYy(item)">去咨询</view>
							<view class="setBtn viewDet" v-else @tap.stop="againBuyZxTc(item.tcId)">再次购买</view>
						</template>
						<template v-else>
							<view class="setBtn fix" @tap.stop="goPjPage(index,item.id)" v-if="item.pjId == ''">去评价</view>
							<view v-else class="setBtn viewDet" @tap.stop="viewPjPage(item.pjId)">查看评价</view>
						</template>
					</block>
					<block v-if="item.status == 7">
						<view class="setBtn viewDet" @tap.stop="againBuyZxTc(item.tcId)">再次购买</view>
					</block>
				</view>
			</view>
		</view>
		<loading-view :loading="loading"></loading-view>
	</view>
</template>

<script>
	export default {
		props:{
			orderList:Array,
			loading:Boolean,
			currPageType:{//zxOrder zxTcOrder
				type:String,
				default:'zxOrder'
			}
		},
		computed:{
			formatZxFun(){
				return function(str){
					var newStr = '';
					if(str == 1){
						newStr = '视频咨询';
					}else if(str == 2){
						newStr = '电话咨询';
					}else if(str == 3){
						newStr = '面对面咨询';
					}
					return newStr;
				}
			}
		},
		methods:{
			goPay(item){
				this.$emit('goPay',item);
			},
			goPjPage(index,orderId){
				this.$emit('goPjPage',index,orderId);
			},
			viewPjPage(pjId){
				this.$emit('viewPjPage',pjId);
			},
			goOrderDet(item){
				this.$emit('goOrderDet',item);
			},
			cancelOrder(orderId){
				this.$emit('cancelOrder',orderId);
			},//咨询套餐下去咨询预约2024-06-07
			goZxYy(item){
				let { teaUserId,teaName,ustId } = item;
				uni.navigateTo({
					url:'/pages/subIndex/zxsYy/zxsYy?zxsUserId=' + teaUserId + '&zxsName=' + teaName + '&fromPageType=zxTcType&ustId=' + ustId
				})
			},
			againBuyZxTc(tcId){
				this.$emit("againBuyZxTc",tcId);
			},
		}
	}
</script>

<style lang='scss' scoped>
	@import '@/static/scss/orderList.scss'
</style>